﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Furion.DatabaseAccessor;
using Microsoft.AspNetCore.Mvc;
using YShop.Application.Contracts.Shop;
using YShop.Core.Entites;
using Mapster;

namespace YShop.Application.Shop
{
    /// <summary>
    /// 商品
    /// </summary>
    [ApiDescriptionSettings("Shop")]
    public class ProductService : CrudService<Product, ProductDto, ProductDto, PageSearchDto, ProductDto, ProductDto>, IBaseService
    {
        private readonly IRepository<Product> _repository;

        public ProductService(IRepository<Product> repository) : base(repository)
        {
            _repository = repository;
        }

        /// <summary>
        /// 查询列表
        /// </summary>
        /// <param name="pageSearchDto"></param>
        /// <returns></returns>
        public override async Task<PagedList<ProductDto>> GetListAsync([FromQuery] PageSearchDto pageSearchDto)
        {
            return await _repository.Include(s => s.Details, false).ProjectToType<ProductDto>().ToPagedListAsync() ;
        }
    }

}
